<?php
/**
 * Created by PhpStorm.
 * User: gogo
 * Date: 2019/2/22
 * Time: 下午5:23
 */
namespace app\common;

use app\tools\RedisCache;
use think\Request;

class BaseLoginCustomer extends Common
{

    function __construct(Request $request = null)
    {
        parent::__construct($request);
        $this->check();
    }

    function check(){
        $u_id = $this->getParam('u_id', 0);
        $openid = $this->getParam('openid', 0);

        $redis = RedisCache::getInstance();
        $user = $redis->hGetAll("user_info_".$u_id);

        if(!$user){
            exit(fail("NOT_LOGIN"));
        }else{
            if($user['openid'] != $openid){
                exit(fail("ACCOUNT_NOT_EXIST"));
            }
        }

        $this->userInfo = $user;

    }

}